package chapter2;

/**
 * @author Hang
 * @date 2022/8/10
 * @project AutumnOffer
 * @description 面试题10 迭代实现fib
 **/
public class fib {
    public static void main(String[] args) {
        System.out.println(fib(100));
    }
    public static int fib(int n) {
        final int MOD = 1000000007;
        if(n==0) return 0;
        if(n==1) return 1;
        int p=0,q=1,r=0;
        for(int i=2;i<=n;i++){
            r = (p + q)%MOD;
            p = q;
            q = r;
        }
        return r;
    }
}
